﻿<UserControl x:Class="QuanLyKho.ucXuatKho"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
             xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
             xmlns:local="clr-namespace:QuanLyKho"
             Loaded="UserControl_Loaded"
    >
    <UserControl.Resources>
        <Style TargetType="Label">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="5,0,0,0" />
        </Style>
        <Style TargetType="dxe:DateEdit">
            <Setter Property="Margin" Value="2,2" />
        </Style>
        <Style TargetType="dxe:TextEdit">
            <Setter Property="Margin" Value="2,2" />
        </Style>
    </UserControl.Resources>
    <UserControl.CommandBindings>
        <CommandBinding Command="{x:Static local:ucXuatKho.FocusHomeCommand}" Executed="FocusHomeCommandExecute" CanExecute="FocusHomeCommandCanExecute" />
    </UserControl.CommandBindings>
    <UserControl.InputBindings>
        <KeyBinding Command="{x:Static local:ucXuatKho.FocusHomeCommand}" Key="G" Modifiers="Alt" />
    </UserControl.InputBindings>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="70"></RowDefinition>
            <RowDefinition ></RowDefinition>
            <RowDefinition Height="42"></RowDefinition>
        </Grid.RowDefinitions>
        <GroupBox Grid.Row="0" Header="Thông tin phiếu xuất" Margin="2 2 2 2">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="28"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="90"></ColumnDefinition>
                    <ColumnDefinition MinWidth="100"></ColumnDefinition>
                    <ColumnDefinition Width="60"></ColumnDefinition>
                    <ColumnDefinition MinWidth="100"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Text="Số Phiếu Xuất:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <dxe:TextEdit x:Name="txtIdPhieuXuat" Grid.Column="1" Grid.Row="0" VerticalAlignment="Center"
                              IsReadOnly="True" 
                              HorizontalContentAlignment="Center" FontSize="15" FontWeight="Bold" 
                              Foreground="Red" Background="Aqua"/>
                <TextBlock Text="Ngày xuất:" Grid.Column="2" Grid.Row="0" Margin="2 2 2 2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <dxe:DateEdit Grid.Column="3" Grid.Row="2" TabIndex="1" Name="deNgayXuat"
                      Mask="dd/MM/yyyy" MaskAutoComplete="Optimistic" 
                      InvalidValueBehavior="AllowLeaveEditor"
                      MaskType="DateTimeAdvancingCaret" DisplayFormatString="dd/MM/yyyy"
                      EditValueChanging="deNgayXuat_EditValueChanging" 
                      Validate="deNgayXuat_Validate"/>
            </Grid>
        </GroupBox>
        <dxg:GridControl Name="gridChiTiet" Grid.Row="1" TabIndex="2" AutoExpandAllGroups="True">
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="PhieuNhapThuocChiTiet.MaThuoc" Header="Mã Vật Tư" Width="50" Name="colMaThuoc" Validate="colMaThuoc_Validate"/>
                <dxg:GridColumn FieldName="PhieuNhapThuocChiTiet.TenThuoc" Header="Tên vật tư" Name="colTenThuoc"/>
                <dxg:GridColumn FieldName="PhieuNhapThuocChiTiet.TenHamLuong" Header="Hàm lượng" Width="60" ReadOnly="True"/>
                <dxg:GridColumn FieldName="PhieuNhapThuocChiTiet.TenDonViTinh" Header="ĐVT" Width="60" ReadOnly="True"/>
                <dxg:GridColumn FieldName="SoLuong" Header="SL" Width="40" Name="colSoLuong" Validate="colSoluong_Validate">
                    <dxg:GridColumn.EditSettings>
                        <dxe:TextEditSettings MaskType="Numeric"/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
                <dxg:GridColumn FieldName="GiaXuat" Header="Giá bán" Width="60" Name="colGiaXuat" Validate="colGiaXuat_Validate">
                    <dxg:GridColumn.EditSettings>
                        <dxe:TextEditSettings MaskType="Numeric" Mask="c0" MaskUseAsDisplayFormat="True" MaskCulture="Vietnamese (Vietnam)"/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
                <dxg:GridColumn FieldName="ThanhTien" Header="Thành tiền" ReadOnly="True" UnboundType="Decimal" UnboundExpression="[GiaXuat] * [SoLuong]" Width="60">
                    <dxg:GridColumn.EditSettings>
                        <dxe:TextEditSettings MaskType="Numeric" Mask="c0" MaskUseAsDisplayFormat="True" MaskCulture="Vietnamese (Vietnam)" />
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
                <dxg:GridColumn FieldName="PhieuNhapThuocChiTiet.TenNhaPhanPhoi" Header="Nhà phân phối" ReadOnly="True" Name="colNhaPhanPhoi"/>
                <dxg:GridColumn FieldName="PhieuNhapThuocChiTiet.SoLo" Header="Số lô" ReadOnly="True">
                    <dxg:GridColumn.EditSettings>
                        <dxe:TextEditSettings HorizontalContentAlignment="Left"/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
                <dxg:GridColumn FieldName="PhieuNhapThuocChiTiet.SoLuongConLai" Header="SL còn lại" ReadOnly="True" Name="colSLConLai">
                    <dxg:GridColumn.EditSettings>
                        <dxe:TextEditSettings HorizontalContentAlignment="Left"/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
            </dxg:GridControl.Columns>
            <dxg:GridControl.TotalSummary>
                <dxg:GridSummaryItem FieldName="ThanhTien" SummaryType="Sum" DisplayFormat="Tổng tiền: {0:n0} đ " />
            </dxg:GridControl.TotalSummary>
            <dxg:GridControl.View>
                <dxg:TableView Name="tbvChiTiet" TabIndex="4" ShowTotalSummary="True" AllowColumnFiltering="True" ShowAutoFilterRow="True"
                               ShowGroupPanel="False" AutoWidth="True" NewItemRowPosition="Top" AllowGrouping="True"
                               PreviewKeyDown="tbvChiTiet_PreviewKeyDown"
                               CellValueChanged="tbvChiTiet_CellValueChanged"
                               FocusedRowChanged="tbvChiTiet_FocusedRowChanged"
                               ValidateRow="tbvChiTiet_ValidateRow" 
                               InvalidRowException="tbvChiTiet_InvalidRowException" 
                               InitNewRow="tbvChiTiet_InitNewRow"
                               PreviewMouseLeftButtonDown="tbvChiTiet_PreviewMouseLeftButtonDown"
                               RowUpdated="tbvChiTiet_RowUpdated"
                               />
            </dxg:GridControl.View>
        </dxg:GridControl>
        <dxb:BarManager Name="barManagerButton" Grid.Row="2" Grid.ColumnSpan="4" CreateStandardLayout="True">
            <dxb:BarManager.Items>
                <!--Regular bar items-->
                <dxb:BarButtonItem x:Name="btnThemMoi" Content="_Thêm mới" BarItemDisplayMode="ContentAndGlyph"  
                                   LargeGlyph ="Images/Icons/new-32x32.png" ItemClick="btnThemMoi_ItemClick" />
                <dxb:BarButtonItem x:Name="btnLuu" Content="_Lưu" BarItemDisplayMode="ContentAndGlyph"  
                                   LargeGlyph ="Images/Icons/save.png" ItemClick="btnLuu_ItemClick" />
                <dxb:BarButtonItem x:Name="btnXoa" Content="_Xóa" BarItemDisplayMode="ContentAndGlyph" 
                                   LargeGlyph ="Images/Icons/deletered.png" ItemClick="btnXoa_ItemClick" />
                <dxb:BarButtonItem x:Name="btnHuyBo" Content="_Hủy bỏ" BarItemDisplayMode="ContentAndGlyph" 
                                   LargeGlyph ="Images/Icons/undo.png" ItemClick="btnHuyBo_ItemClick" />
                <dxb:BarButtonItem x:Name="btnDong" Content="Đó_ng" BarItemDisplayMode="ContentAndGlyph" 
                                   LargeGlyph ="Images/Icons/logout.png" ItemClick="btnDong_ItemClick" />
            </dxb:BarManager.Items>
            <!--Create two bars-->
            <dxb:BarManager.Bars>
                <dxb:Bar>
                    <dxb:Bar.ItemLinks>
                        <dxb:BarItemLink BarItemName="btnThemMoi"/>
                        <dxb:BarItemLink BarItemName="btnLuu"/>
                        <dxb:BarItemLink BarItemName="btnXoa"/>
                        <dxb:BarItemLink BarItemName="btnHuyBo"/>
                        <dxb:BarItemLink BarItemName="btnDong"/>
                    </dxb:Bar.ItemLinks>
                </dxb:Bar>
            </dxb:BarManager.Bars>
        </dxb:BarManager>
    </Grid>
</UserControl>
